package com.novel.controller.novel;

import com.novel.controller.other.BaseController;
import com.novel.pojo.novel.NovelRecommend;
import com.novel.service.NovelRecommendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("novel/recommend")
public class NovelRecommendController extends BaseController {

    @Autowired
    private NovelRecommendService recommendService;

    /**
     * 推荐小说
     */
    @PostMapping("{novelId}")
    public boolean recommendNovel(@PathVariable("novelId") String novelId) {
        //封装数据
        NovelRecommend recommend = new NovelRecommend();
        recommend.setUserId(getUserInformation().getUserId());
        recommend.setNovelId(novelId);
        recommend.setCreatedIp(getUserIpAddress());
        //保存返回
        return recommendService.insertRecommendInfo(recommend);
    }

}